﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ModelLayer;
using Client.Service;

namespace Client
{
    public partial class SearchCustomerGUI : Form
    {
        private ICustomer customerService;

        public SearchCustomerGUI()
        {
            InitializeComponent();
            customerService = new CustomerClient("BasicHttpBinding_ICustomer");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string phoneNo = textBox1.Text;
            Customer cus = customerService.GetCustomerByPhoneNo(phoneNo);
            if (cus != null)
            {
                textBoxName.Text = cus.FName;
                textBoxAddress.Text = cus.Address;
                textBoxPostal.Text = cus.PostalCode.ToString();
                textBoxCity.Text = cus.City;
                textBoxEmail.Text = cus.Email;
            }
            else
            {
                MessageBox.Show("no customer found" + phoneNo.ToString());
            }
        }
    }
}
